<?php
// +----------------------------------------------------------------------
// | [ WE ONLY DO WHAT IS NECESSARY ]
// +----------------------------------------------------------------------
// | Author < 931274989@qq.com >
// +----------------------------------------------------------------------
// | Explain 公众号菜单
// +----------------------------------------------------------------------
namespace app\ymkj\controller;

use EasyWeChat\Foundation\Application;
use think\facade\Config;
use think\Controller;
 
class Menu extends Controller
{
  // 创建自定义菜单
  public function createMenu()
  {
    $options = Config::get('wewhat.wxConfig');
    $app = new Application($options);
    $menu = $app->menu;
    $buttons = [
      [
        "name"       => "公司简介",
        "sub_button" => [
          [
            "type" => "view",
            "name" => "公司网站",
            "url"  => "http://www.cfyunmeng.com/m/index.html"
          ],
          [
            "type" => "click",
            "name" => "客服电话",
            "key"  => "key001"
          ],
        ],
      ],
      [
        "name"       => "专享服务",
        "sub_button" => [
          [
            "type" => "view",
            "name" => "专享旅游",
            "url"  => "http://yunnuo.chirongkeji.com/index.php/Home/Tourism/index.html?code=071dMrrp0cfunn18S0qp01CQrp0dMrre&state=STATE"
          ],
          [
            "type" => "view",
            "name" => "九折加油",
            "url"  => "https://wx.enjoycar.net/share/coupon/?mobile=15774809666"
          ],
          [
            "type" => "view",
            "name" => "老兵代驾",
            "url"  => "https://admin.zg-dj.com/WeiXin/WeiXinDuan/DaiJiaXiaDanWeb.aspx"
          ],
          [
            "type" => "view",
            "name" => "优惠洗车",
            "url"  => "http://cfymkj58.com/ymkj/qcfu/index"
          ],
          [
            "type" => "view",
            "name" => "优惠保养",
            "url"  => "http://cfymkj58.com/ymkj/qcfu/baoyang"
          ],
        ],
      ],
      [
        "name"       => "会员中心",
        "sub_button" => [
          [
            "type" => "view",
            "name" => "个人中心",
            "url"  => Config::get('wewhat.HTTP')."/ymkj/user/index"
          ],
        ],
      ],
    ];
    $menu->destroy();
    $menu->add($buttons);
    if( $menu ){
      return '设置成功';
    }
  }

}
?>